package com.maomao.maomaochong_i.quanxing.PhoneData;


import com.maomao.maomaochong_i.quanxing.PhoneData.SendFactory.Factory.GetList;
import com.maomao.maomaochong_i.global.Show;
import com.maomao.maomaochong_i.quanxing.PhoneData.SendFactory.SendShowFactory;
import com.maomao.maomaochong_i.quanxing.ShanPingShuJu;

import java.util.ArrayList;


/**
 * Created by Mrma on 17.5.22.
 */

public class PhoneData{
    private ArrayList<ShanPingShuJu>  list;
    private ArrayList<String> biaoti = new ArrayList<>();//收集的名字
    private ArrayList<String> jiage = new ArrayList<>();//价格
    private ArrayList<Integer> tupian = new ArrayList<>();//图片


    private static PhoneData quanXingShuJu;

    public static PhoneData getOne() {
        if (quanXingShuJu == null)
            quanXingShuJu = new PhoneData();
        return quanXingShuJu;
    }

    public void add(ShanPingShuJu shuju) {
        list.add(shuju);
    }


    private GetList shulist;
    public void classfiy(Show show){
        switch (show){
            case NEWPHONE:
                shulist = SendShowFactory.makeShow(Show.NEWPHONE);
                break;
            case SENCONEDPHOE:
                shulist = SendShowFactory.makeShow(Show.SENCONEDPHOE);
                break;
            case INTERESSTION:
                shulist = SendShowFactory.makeShow(Show.INTERESSTION);
                break;
            case PHONEACCESSORIES:
                shulist = SendShowFactory.makeShow(Show.PHONEACCESSORIES);
                break;
        }
        ArrayList list = (ArrayList) shulist.getList();
        biaoti = (ArrayList<String>) list.get(0);
        jiage = (ArrayList<String>) list.get(1);
        tupian = (ArrayList<Integer>) list.get(2);
        get();
    }
    private void get() {
        list = new ArrayList<>();
        for (int i = 0; i < biaoti.size(); i++) {
            ShanPingShuJu shanPingShuJu = new ShanPingShuJu();
            shanPingShuJu.setBiao(biaoti.get(i));
            shanPingShuJu.setJiage(jiage.get(i));
            shanPingShuJu.setTu(tupian.get(i));
            list.add(shanPingShuJu);
        }

    }

    public ArrayList<ShanPingShuJu> getList() {

        return list;
    }
}
